package com.itheima.thread.communication.demo02;

public class ProducerThread implements Runnable {

    private Box box;
    public ProducerThread(Box box) {
        this.box = box;
    }

    private int count = 0;

    @Override
    public void run() {

        while (true) {

            synchronized (box) {

                if(count % 2 == 0) {
                    box.setMilkType("牛奶");
                    box.setAmount("5L");
                }else {
                    box.setMilkType("羊奶");
                    box.setAmount("10L");
                }

            }

            count++;

        }

    }

}
